/**
 * 
 */
package edu.pw.treegrid.server.query;


/** 
 * @author Xalan
 */
public class Query {
	private String select = "";

	public String getSelect() {
		return select;
	}

	public void setSelect(String select) {
		this.select = select;
	}

	private String from = "";

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	private String where = "";

	public String getWhere() {
		return where;
	}

	public void setWhere(String where) {
		this.where = where;
	}

	private String groupBy = "";

	public String getGroupBy() {
		return groupBy;
	}

	public void setGroupBy(String groupBy) {
		this.groupBy = groupBy;
	}

	public String getQuery() {
		StringBuilder sb = new StringBuilder();
		sb.append("SELECT");
		sb.append(select);
		sb.append("\nFROM");
		sb.append(from);
		if (!where.isEmpty()) {
			sb.append("\nWHERE\n");
			sb.append(where);
		}
		if (!groupBy.isEmpty()) {
			sb.append("\nGROUP BY");
			sb.append(groupBy);
		}
		return sb.toString();
	}
}